int cmp(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}

int countElements(int *nums, int numsSize)
{
    qsort(nums, numsSize, sizeof(int), cmp);
    int count = 0;
    for (int i = 1; i < numsSize - 1; ++i)
    {
        if (nums[i] != nums[0] && nums[i] != nums[numsSize - 1])
        {
            ++count;
        }
    }
    return count;
}